var webpack = require("webpack")
var path = require("path")
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
    mode: 'production',
    entry: './app.js',
    output: {
        filename: 'bundle.js',
        path: path.join(__dirname, './dist')
    },
    module: {
        rules: [
            { test: /\.css$/, loader: 'style-loader!css-loader' },
            { test: /\.vue$/, loader: 'vue-loader' },
            {
                test: /\.(gif|jpg|svg|png)$/, loader: 'url-loader',
                // 将小于8K的图片以base64的形式打包到js文件中
                options: {
                    limit: 8192
                }
            },
            // { test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader' },
            {
                test: /\.scss$/, use: [
                    'style-loader',
                    'css-loader',
                    'sass-loader'
                ]
            },
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: '测试',
            template: path.join(__dirname, 'index.html'),
            inject: true,
        })
        // new webpack.hotModuleReplacementPlugin()
    ],
    devServer: {
        headers: {
            "X-Custom-Foo": "bar"
        },
        inline: true,
        // hot: true,
        open: 'localhost:9000',
        stats: "errors-only", // minimal"，"normal"，"verbose 打印信息类型
        contentBase: path.join(__dirname, '/'),
        compress: true, // gzip 压缩 给双端带来压力 但是提高访问速度
        port: 9000
    }
}